<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta http-equiv="pragram" content="no-cache">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>[title]</title>
    <link href="/Public/Home/css/style.css" rel="stylesheet" type="text/css">
    <link href="/Public/Home/css/iconfont.css" rel="stylesheet" type="text/css">
    <script src="/Public/Home/js/jquery-1.11.1.min.js"></script>
    <script src="/Public/Home/js/publicjquery.js"></script>
    <script src="/Public/Home/js/layer/layer.js" ></script>
    <script src="/Public/Home/js/common.js" ></script>
    <script src="/Public/Home/js/ajaxfileupload.js" ></script>
</head>
<body onselectstart="return false">
<div class="main FromUpToDown" >
    <div class="content" style="position: relative">
        <div class="head-content">
            <div class="head-title">
                <span><?php echo ACTION_NAME == 'edit' ? '修改' : '添加';?>货柜</span>
            </div>
        </div>
        <form action='' id="form" >
            <div class="form-content">
                <div class="form">
                    <div class="form-left">货柜编号</div>
                    <div class="form-right">
                        <input class="form-input-small" type="text" name='no'  value="<?php echo ($info['no']); ?>" placeholder="货柜编号"  />
                    </div>
                </div>
                <div class="form">
                    <div class="form-left">容量</div>
                    <div class="form-right">
                        <input class="form-input-small" type="text" name='capacity'  value="<?php echo ($info['capacity']); ?>" placeholder="容量"  />
                    </div>
                </div>
                <div class="form">
                    <div class="form-left">已使用</div>
                    <div class="form-right">
                        <input class="form-input-small" type="text" name='used'  value="<?php echo ($info['used']); ?>" placeholder="已使用"  />
                    </div>
                </div>
                <div class="form">
                    <div class="form-left">排序</div>
                    <div class="form-right">
                        <input class="form-input-small" type="text" name='position'  value="<?php echo ((isset($info['position']) && ($info['position'] !== ""))?($info['position']):0); ?>" placeholder="排序值"  />
                    </div>
                </div>
                <input type='hidden' name='id' value="<?php echo ($info['id']); ?>" >
                <div class="form-operate">
                    <button type='button' id="save"  class="form-button color-bg-green">保存</button>
                    <button type='button' onclick="history.go(-1)" class="form-button color-bg-grey">返回</button>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="main-foot">Copyright  2013-2015 WeiGouTong.com. All Rights Reserved.  苏ICP备09098830号</div>
<script>
    $("#save").click(function(){

        if($("input[name='no']").val() == ''){
            layer.tips('请输入货柜编号！', 'input[name="no"]', {tips: [2, 'red'], time: 1000});
            return;
        }
        if($("input[name='capacity']").val() == ''){
            layer.tips('请输入货柜容量！', 'input[name="capacity"]', {tips: [2, 'red'], time: 1000});
            return;
        }
		if($("input[name='used']").val() > $("input[name='capacity']").val()){
			 layer.tips('请输入合法已使用量！', 'input[name="used"]', {tips: [2, 'red'], time: 1000});
            return;
		}
        $("#save").attr('disabled',true);
        $.post(
                "<?php echo U('save');?>",
                $("#form").serialize(),
                function(res){
                    if(res.status == 1){
                        layer.tips(res.info, '#save', {tips: [2, 'green'], time: 1000});
                        setTimeout("location.href = document.referrer",1000);
                    }else{
                        $("#save").attr('disabled',false);
                        layer.tips(res.info, '#save', {tips: [2, 'red'], time: 1000});
                    }
                }
        );
    });
</script>
</body>
</html>